<?
require ("phpmailer/class.phpmailer.php");
function sendMailFromGmail($from, $fromName, $to, $toName, $user, $password, $subject, $msg) {
	$mail = new PHPMailer ();
	$mail->IsSMTP ();
	$mail->SMTPAuth = true; // enable SMTP authentication
	$mail->SMTPSecure = "tls"; // sets the prefix to the server
	$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
	$mail->Port = 587; // set the SMTP port for the GMAIL server
	$mail->Username = $user; // GMAIL username
	$mail->Password = $password; // GMAIL password
	

	$mail->From = $from;
	$mail->FromName = $fromName;
	$mail->Subject = $subject;
	$mail->MsgHTML ( $msg );
	
	$mail->AddAddress ( $to, $toName );
	//$mail->IsHTML ( true ); // send as HTML
	
	//to see if we return a message or a value bolean
	if (! $mail->Send ()) {
		return true;
	} else {
		return false;
	}
	
	$mail->ClearAddresses ();
	$mail->ClearAttachments ();
}

$to = "doduyhai106@yahoo.com";
$from = "mekiep095@gmail.com";
$password = 'mekiep095106';
$user = $from;
$mail = new PHPMailer ();
$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "tls"; // sets the prefix to the server
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 587; // set the SMTP port for the GMAIL server
$mail->Username = $user; // GMAIL username
$mail->Password = $password; // GMAIL password


$mail->From = $from;
$mail->FromName = "doduyhai106";
$mail->Subject = "yahoo cua ban da bi hack thanh cong";
$mail->MsgHTML ( "<br><br>Chao ban, ban da nhan duoc mail tu".$from );

//$mail->AddReplyTo("reply@email.com","reply name");//they answer here, optional
$mail->AddAddress ( $to, "yahoo" );
$mail->AddAddress ( $from, "gmail" );
$mail->AddAddress ( "doduyhai106@gmail.com", "gmail" );
//$mail->IsHTML ( true ); // send as HTML


//to see if we return a message or a value bolean
if (! $mail->Send ()) {
	echo "<br>Mailer Error: " . $mail->ErrorInfo;
} else {
	echo "Message sent!";
} 

$mail->ClearAddresses(); 
$mail->ClearAttachments(); 

?>
